/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package managed;

import entity.Customer;
import java.util.ArrayList;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.xml.ws.WebServiceRef;
import serviceRest.CustomerClient;
import serviceSoap.CustomerSoapService_Service;

/**
 *
 * @author Human Booster
 */
@ManagedBean
@SessionScoped
public class CustomerController {
    @WebServiceRef(wsdlLocation = "WEB-INF/wsdl/localhost_8080/Licence4-back/CustomerSoapService.wsdl")
    private CustomerSoapService_Service service;

    private CustomerClient customerWS = new CustomerClient();
    private List<Customer> customerList = new ArrayList<Customer>();

    public CustomerController() {
    }

    public String doShowCustomerList() {
//        System.out.println("Debut de traitement : ");
//        Customer test =  customerWS.findAll_XML(Customer.class);
//        System.out.println("test = " + test);
//        String test = customerWS.toString();
//        System.out.println("test = " + test);
//        customerList = (List<Customer>) customerWS.findAll_JSON(Customer.class);
        customerList = (List<Customer>) customerWS.findAll_JSON(Customer.class);
        for (Customer customer : customerList) {
            System.out.println("customer = " + customer);
        }
        return "customer.xhtml";
    }

    public List<Customer> getCustomerList() {
        return customerList;
    }

    public void setCustomerList(List<Customer> customerList) {
        this.customerList = customerList;
    }

    public CustomerClient getCustomerWS() {
        return customerWS;
    }

    public void setCustomerWS(CustomerClient customerWS) {
        this.customerWS = customerWS;
    }

    private java.util.List<serviceSoap.LicenceCustomer> findAll() {
        serviceSoap.CustomerSoapService port = service.getCustomerSoapServicePort();
        return port.findAll();
    }
    
    
}
